home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: Reading Formatted Text
- Sent: 6/11/96 8:27 AM
- Received: 6/11/96 9:12 AM
- From: Serge Froment, sfroment@odyssee.net
- Reply-To: ODF Interest, ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- >As you've noticed, ODF R1 doesn't provide anything that exactly meets your
- >needs. FW_CTextReader is the most appropriate ODF class for this task. The
- >idea is to create tool classes that use TextReader interfaces. For
- >example, you might write a lexical analyzer class along these lines:
-
- Jim:
-
- Thank you for your detailed answer. I ended up doing somewhat what you
- said, using FW_CTextReader::PeekRunAhead to copy the text inside a
- FW_CString where I can search for delimiters. Here is the code a came up
- with:
-
- void CMyData::ReadString(FW_CTextReader& textReader, FW_CString& string,
- FW_LChar delimiter)
- {
- const char* start;
- FW_Boolean seeking = true;
- FW_ByteCount length, del, eol, size = 0;
-
- string.Truncate(0);
- do
- {
- textReader.PeekRunAhead(start, length);
- if (length > 0)
- {
- string.Append(start, length);
- if (string.FindCharacter(delimiter, del, size))
- {
- string.Truncate(del);
- if (string.FindCharacter('\r', eol, size))
- {
- string.Truncate(eol);
- textReader.Advance(eol - size);
- }
- else
- textReader.Advance(del - size + 1);
- seeking = false;
- }
- else if (string.FindCharacter('\r', eol, size))
- {
- string.Truncate(eol);
- textReader.Advance(eol - size);
- seeking = false;
- }
- else
- textReader.Advance(length);
- size = string.GetByteLength();
- }
- }
- while (seeking && length > 0);
- }
-
- However, I am a bit concerned about the efficiency of such a method in the
- case the clipboard contain a large text. (I was done writing the code late
- last evening and I have not yet tested what happen in that case.)
-
- Serge
-
-